<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></script>
    <script type="text/javascript">
    var map = null;
    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(0,0));
        geocoder = new GClientGeocoder();
        var markers = [];
        findLocationAndAddMarker(markers, "madrid", "david");
        findLocationAndAddMarker(markers, "murcia", "alberto");
        findLocationAndAddMarker(markers, "toledo", "john");
        findLocationAndAddMarker(markers, "london", "peter");
      }
    }
    function findLocationAndAddMarker(markers, address, label)
    {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            addMarker(point, label);
            markers.push(point);
            setCenter(map,markers);
          }
        );
      }  
    }
    function addMarker(point, label)
    {
      var marker = new GMarker(point);
      GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(label);
      });
      map.addOverlay(marker);
    }
    function setCenter(map,pointArray){
      var north =  -90;
      var south =   90;
      var east  = -180;
      var west  =  180;
      pointArray.forEach(function(point){
        if(north < point.lat())
           north = point.lat();
        if(south > point.lat())
           south = point.lat();
        if(east  < point.lng())
           east  = point.lng();
        if(west  > point.lng())
           west  = point.lng();
      });
      var latitudeAvg  = Math.abs((north-south)/2);
      var longitudeAvg = Math.abs((west-east)/2);
      var bounds = new GLatLngBounds(new GLatLng(south,west), new GLatLng(north,east));
      var zoom = map.getBoundsZoomLevel(bounds);
      map.setCenter(new GLatLng(south+latitudeAvg,west+longitudeAvg), zoom);
    }
    </script>
  </head>
  <body onload="initialize()" onunload="GUnload()">
    <div id="map_canvas" style="width: 500px; height: 300px"></div>
  </body>
</html>
